<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('发放许可证')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-leave-edit" th:object="${bizLeave}">
        <input name="id" th:field="*{id}" type="hidden">
        <input name="taskId" th:field="*{taskId}" type="hidden">
        <input name="p_DT_realityStartTime" type="hidden"/>
        <input name="p_DT_realityEndTime" type="hidden"/>
        <div class="form-group">
            <label class="col-sm-3 control-label">申请人：</label>
            <div class="col-sm-8">
                <input class="form-control" name="applyUserName" readonly th:field="*{applyUserName}" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">申请时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input class="form-control" disabled name="applyTime"
                           th:value="${#dates.format(bizLeave.applyTime, 'yyyy-MM-dd HH:mm')}" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">许可证类型：</label>
            <div class="col-sm-8">
                <select class="form-control m-b" name="type" th:with="type=${@dict.getType('biz_leave_type')}">
                    <option th:each="dict : ${type}" th:field="*{type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">标题：</label>
            <div class="col-sm-8">
                <input class="form-control" name="title" readonly th:field="*{title}" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">原因：</label>
            <div class="col-sm-8">
                <textarea class="form-control" name="reason" readonly>[[*{reason}]]</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">开始时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input class="form-control calcTotalSecondInput" disabled name="startTime" placeholder="yyyy-MM-dd"
                           th:value="${#dates.format(bizLeave.startTime, 'yyyy-MM-dd HH:mm')}" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">结束时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input class="form-control calcTotalSecondInput" disabled name="endTime" placeholder="yyyy-MM-dd"
                           th:value="${#dates.format(bizLeave.endTime, 'yyyy-MM-dd HH:mm')}" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">许可证时长：</label>
            <div class="col-sm-8">
                <input class="form-control" name="totalTime" style="display: none;" th:field="*{totalTime}" type="text">
                <input class="form-control" name="totalTimeText" readonly type="text">
            </div>
        </div>
        <hr/>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>实际开始时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input class="form-control" name="realityStartTime" placeholder="yyyy-MM-dd HH:mm" required
                           th:value="${#dates.format(bizLeave.startTime, 'yyyy-MM-dd HH:mm')}" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>实际结束时间</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input class="form-control" name="realityEndTime" placeholder="yyyy-MM-dd HH:mm" required
                           th:value="${#dates.format(bizLeave.endTime, 'yyyy-MM-dd HH:mm')}" type="text">
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "leave";
    $("#form-leave-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $('input[name="p_DT_realityStartTime"]').val($('input[name="realityStartTime"]').val());
            $('input[name="p_DT_realityEndTime"]').val($('input[name="realityEndTime"]').val());
            var taskId = [[${taskId}]];
            $.operate.save(prefix + "/complete/" + taskId, $('#form-leave-edit').serialize());
        }
    }

    $("input[name='realityStartTime']").datetimepicker({
        autoclose: true
    });

    $("input[name='realityEndTime']").datetimepicker({
        autoclose: true
    });

    $(function () {
        var leave = [[${bizLeave}]];
        var dateSub = formatTotalDateSub(leave.totalTime);
        $('input[name="totalTimeText"]').val(dateSub);

        $('select[name="type"]').prop('disabled', true);
    });
</script>
</body>
</html>
